package com.tang.websocket.spring;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

import javax.annotation.Resource;

/**
 * @Classname WebSocketConfig
 * @Description [ TODO ]
 * @Author Tang
 * @Date 2020/10/3 14:24
 * @Created by ASUS
 */
@EnableWebSocket
@Configuration
public class SpringWebSocketConfig implements WebSocketConfigurer {

    @Resource
    SimpleWebSocket1 simpleWebSocket1;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(simpleWebSocket1, "/simple1/{id}")
                .setAllowedOrigins("*");
    }


}